import axios from "axios"


// 我的获取播放列表
async function GetPlayList(){
  var result
  await axios({
      baseURL: 'api/playlist/getmyplaylist',
      method: 'get',
  }).then(res => {
      result=res.data
      console.log(result);
  })
  return result
}

// 添加音乐到播放列表
async function Add2PlayList(TbMusic){
  var result
  await axios({
      baseURL: 'api/playlist/add',
      data: TbMusic,
      headers: {'Content-Type': 'application/json;charset=UTF-8' },
      method: 'post',
  }).then(res => {
      result=res.data
      console.log(result);
  })
  return result
}

//    添加多个音乐到播放列表
async function Add2PlayList2(musicList){
  var result
  await axios({
      baseURL: 'api/playlist/add2playList2',
      data: musicList,
      headers: {'Content-Type': 'application/json;charset=UTF-8' },
      method: 'post',
  }).then(res => {
      result=res.data
      console.log(result);
  })
  return result
}

// //    根据MusicId删除播放列表音乐
async function delete2PlayList( musicId){
  var result
  await axios({
      baseURL: 'api/playlist/delete?musicId='+musicId,
      method: 'delete',
  }).then(res => {
      result=res.data
      console.log(result);
  })
  return result
}
// //    删除当前用户播放列表所有音乐
async function deleteAll2PlayList(){
  var result
  await axios({
      baseURL: 'api/playlist/deleteall',
      method: 'delete',
  }).then(res => {
      result=res.data
      console.log(result);
  })
  return result
}

// 将收藏夹的音乐添加到播放列表
async function Collect2playlist(collectId){
  var result
  await axios({
      baseURL: 'api/playlist/collect2playlist/'+collectId,
      method: 'post',
  }).then(res => {
      result=res.data
      console.log(result);
  })
  return result
}

export default {
  name: 'PlayListAPI',
  GetPlayList,
  Add2PlayList,
  Add2PlayList2,
  delete2PlayList,
  deleteAll2PlayList,
  Collect2playlist
}
